#include <vector>
#include <queue>

using namespace std;

class Solution {
public:
    int partitionDisjoint(vector<int>& nums) {
        priority_queue<int> leftMax;
        leftMax.emplace(nums[0]);
        for (int i = 1; i < nums.size();) {
            auto it = min_element(nums.begin() + i, nums.end());
            if (leftMax.top() <= *it) {
                return leftMax.size();
            }
            int j = it - nums.begin();
            while (i <= j) {
                leftMax.emplace(nums[i]);
                ++i;
            }
        }
        return leftMax.size();
    }
};